package com.wholesale;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;

import com.wholesale.utils.MyOrderListAdapter;

public class MyTracDetailLayout extends LinearLayout implements OnClickListener{   
	private ViewFlipper viewFlipper ;
	private Context context ;
	private View baseView ;
	private Button leftButton ;
	private Button rightButton ;
	private TextView headView ;
	private MyOrderListAdapter listAdapter;
	private TextView goodsSn,consignee,phone,address,zipcode,orderstatus,shippingmethod,
			paymethod,generation,delivery,goodsid,goodsName,number,price,goodprice,shippingfee,
			totalprice;
	private int orderid;
//	private MyOrdersDetailAsync detailAsy;
	//  构造函数  
	public MyTracDetailLayout(Context context,final ViewFlipper viewFlipper,int orderid){
		super(context);
		this.viewFlipper = viewFlipper ;
		this.context = context ;
		this.orderid = orderid;
//		detailAsy = new MyOrdersDetailAsync(context);
//		detailAsy.execute(false);
		//加载需要的属性，加载方法一的子Layout  
		baseView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.mytracdetail, this);  
		leftButton = (Button)baseView.findViewById(R.id.leftBtn);
		leftButton.setText("Back");
		leftButton.setOnClickListener(this);
		rightButton = (Button)baseView.findViewById(R.id.rightBtn);
		rightButton.setVisibility(View.INVISIBLE);
		headView = (TextView)baseView.findViewById(R.id.title);
		headView.setVisibility(View.INVISIBLE);
		
        goodsSn = (TextView) findViewById(R.id.goodssn_text);
        consignee =  (TextView) findViewById(R.id.consignee_text);
        phone=  (TextView) findViewById(R.id.phone_text);
        address = (TextView) findViewById(R.id.address_text);
        zipcode = (TextView) findViewById(R.id.zipcode_text);
        orderstatus = (TextView) findViewById(R.id.goodstatus_text);
        shippingmethod = (TextView) findViewById(R.id.shipping_text);
        paymethod = (TextView) findViewById(R.id.pay_text);
        generation = (TextView) findViewById(R.id.generation_text);
        delivery = (TextView) findViewById(R.id.delivery_text);
        goodsid =  (TextView) findViewById(R.id.goodsid_text);
        goodsName = (TextView) findViewById(R.id.goodsname_text);
        number = (TextView) findViewById(R.id.number_text);
        price = (TextView) findViewById(R.id.price_text);
        goodprice = (TextView) findViewById(R.id.goodprice_text);
        shippingfee = (TextView) findViewById(R.id.shippingfee_text);
        totalprice = (TextView) findViewById(R.id.total_text);
	}
	//ListView 点击事件
    OnItemClickListener moreClieckListener = new OnItemClickListener() {
    	public void onItemClick(AdapterView<?> arg0, View arg1,
				int arg2, long arg3) {
    		OrderDetailLayout orderDetailLayout = new OrderDetailLayout(context, viewFlipper, 0);
    		viewFlipper.addView(orderDetailLayout);
    		viewFlipper.showNext();
		}
    };

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.leftBtn:
			viewFlipper.showPrevious();
			viewFlipper.removeView(this);
			break;
		case R.id.under_low_to_high:
			
			break;

		case R.id.under_high_to_low:
			
			
			break;

		default:
			break;
		}
		
	}
	
	
//	class MyOrdersDetailAsync extends
//			AsyncTask<Boolean, Integer, OrderDetail> {
//		ProgressDialog pdialog;
//
//		public MyOrdersDetailAsync(Context context) {
//			pdialog = new ProgressDialog(context);
//			pdialog.setTitle("Loading...");
//			pdialog.setMessage("Please wait...");
//			pdialog.setCancelable(true);
//			pdialog.setButton("cancel", new DialogInterface.OnClickListener() {
//				public void onClick(DialogInterface dialog, int i) {
//					dialog.cancel();
//					MyOrdersDetailAsync.this.cancel(true);
//				}
//			});
//			pdialog.show();
//		}
//
//		@Override
//		protected OrderDetail doInBackground(Boolean... params) {
//			
//			OrderDetail orderDetail = WebServiceClient.getOrderDetail(orderid,Constants.loginResponse.getUserId(),Constants.loginResponse.getUserToken());
//			if (orderDetail == null) {
//				return new OrderDetail();
//			} else {
//				return orderDetail;
//			}
//		}
//
//		@Override
//		protected void onPostExecute(OrderDetail result) {
///*			if(result.getGoodsSn()!=null){
//				goodsSn.setText(result.getGoodsSn());
//			}
//			
//			if(order.getConsignee()!=null){
//				consignee.setText(order.getConsignee());
//			}
//			if(order.getMobile()!=null){
//				phone.setText(order.getMobile());
//			}
//			
//			if(order.getAddress()!=null){
//				address.setText(order.getAddress());
//			}
//			
//			if(order.getZipcode()!=null){
//				zipcode.setText(order.getZipcode());
//			}
//			
//			
//			orderstatus.setText(order.getOrderStatus()+"");
//			
//			if(order.getShippingName()!=null){
//				shippingmethod.setText(order.getShippingName());
//			}
//			
//			if(order.getPayName()!=null){
//				paymethod.setText(order.getPayName());
//			}
//			
//			if(order.getAddTime()!=null){
//				generation.setText(order.getAddTime()+"");
//			}
//			
//			if(order.getShippingTime()!=null){
//				delivery.setText(order.getShippingTime()+"");
//			}
//			
//			
//			goodsid.setText(result.getGoodsId()+"");
//			
//			if(result.getGoodsName()!=null){
//				goodsName.setText(result.getGoodsName());	
//			}
//			
//			number.setText(result.getGoodsNumber()+"");
//			price.setText(result.getGoodsNumber()*result.getGoodsPrice()+"");
//			
//			goodprice.setText(order.getGoodsAmount()+"");
//			
//			shippingfee.setText(order.getShippingFee()+"");
//			totalprice.setText(order.getOrderAmount()+"");*/
//			pdialog.dismiss();
//		}
//
//		@Override
//		protected void onCancelled() {
//			super.onCancelled();
//		}
//	}
	
}
